package com.ruihang.generalibrary.utils;

import android.support.annotation.NonNull;
import android.text.TextUtils;

/**
 * Created by liuyu on 2017/8/9.
 */

public class UrlUtils {

    public static String linkUrls(@NonNull String baseUrl, String method) {
        if (method == null) {
            return baseUrl;
        }
        String tempMethod = method.toLowerCase();
        if (TextUtils.isEmpty(tempMethod) || TextUtils.equals(tempMethod, "/")) {
            return baseUrl;
        }
        method = method.trim();
        if (tempMethod.startsWith("http://") || tempMethod.startsWith("https://") || tempMethod.startsWith("rtmp://")) {
            return method;
        }
        if (method.startsWith("/")) {
            method = method.substring(1);
        }
        return baseUrl + method;
    }
}
